<template>
  <div>
    <div class="scl"><SearchLine :is="true" @search-info="search1()" /></div>
    <div class="tl"><TaskList /></div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import SearchLine from '@/components/AppProvider/searchline/index.vue'
import TaskList from '@/components/AppProvider/tasklist/index.vue'
import { onMounted } from 'vue'
import { searchHistory } from '@/api/post'
import { createLocalStorage } from '@/utils/cache'
const tasks = ref([
  {
    create_at: null,
    task_name: 'ht',
    times: '1',
    account: '10',
    description:
      '立长但内近百下政门工保电经。都快联律离十且华西下音着真国林据。斗周电强己其酸美调第构品头。式近意具流从文或深当矿因当化七。',
    status: '1',
    balance: null,
    type: '1',
    path: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F4k%2Fs%2F02%2F210924233115O14-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1656723242&t=7fa47b53f0e7cda6ece74c31c6de7d52',
    task_id: 1,
  },
])
onMounted(() => {
  const ls = createLocalStorage({ prefixKey: 'login_' })
  const user = ls.get('loginInfo')
  console.log('user.userid')
  console.log(user.userid)
  search(user.userid)
})
// async function search1() {
//   const res = await searchHistory({
//     userid: 1,
//   })
//   // console.log(res)
//   tasks.value = res
// }
async function search(id) {
  const res = await searchHistory({
    userid: id,
  })
  tasks.value = res
  // tasks.value = [
  //   {
  //     create_at: null,
  //     task_name: 'ht',
  //     description:
  //       '立长但内近百下政门工保电经。都快联律离十且华西下音着真国林据。斗周电强己其酸美调第构品头。式近意具流从文或深当矿因当化七。',
  //     status: '1',
  //     account: null,
  //     type: '1',
  //     path: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F4k%2Fs%2F02%2F210924233115O14-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1656723242&t=7fa47b53f0e7cda6ece74c31c6de7d52',
  //     task_id: 1,
  //   },
  //   {
  //     create_at: null,
  //     task_name: 'lbj',
  //     description:
  //       '立长但内近百下政门工保电经。都快联律离十且华西下音着真国林据。斗周电强己其酸美调第构品头。式近意具流从文或深当矿因当化七。',
  //     status: '0',
  //     account: null,
  //     type: '2',
  //     path: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2Ftp09%2F21031FKU44S6-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1656723242&t=e84685c9a7badca4e7014287eb91f8ed',
  //     task_id: 2,
  //   },
  //   {
  //     create_at: null,
  //     task_name: 'ht',
  //     description:
  //       '立长但内近百下政门工保电经。都快联律离十且华西下音着真国林据。斗周电强己其酸美调第构品头。式近意具流从文或深当矿因当化七。',
  //     status: '1',
  //     account: null,
  //     type: '1',
  //     path: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F4k%2Fs%2F02%2F210924233115O14-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1656723242&t=7fa47b53f0e7cda6ece74c31c6de7d52',
  //     task_id: 1,
  //   },
  //   {
  //     create_at: null,
  //     task_name: 'chy',
  //     description: 'test3',
  //     status: '1',
  //     account: null,
  //     type: '3',
  //     path: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F1114%2F0G020114924%2F200G0114924-15-1200.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1656723242&t=a73b6fde87d55e3607e1a0677cf5f094',
  //     task_id: 3,
  //   },
  // ]

  // console.log('父组件更新完成')
  // console.log(res)
  // console.log([
  //   {
  //     create_at: null,
  //     task_name: 'ht',
  //     description:
  //       '立长但内近百下政门工保电经。都快联律离十且华西下音着真国林据。斗周电强己其酸美调第构品头。式近意具流从文或深当矿因当化七。',
  //     status: '1',
  //     balance: null,
  //     type: '1',
  //     path: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F4k%2Fs%2F02%2F210924233115O14-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1656723242&t=7fa47b53f0e7cda6ece74c31c6de7d52',
  //     task_id: 1,
  //   },
  //   {
  //     create_at: null,
  //     task_name: 'lbj',
  //     description:
  //       '立长但内近百下政门工保电经。都快联律离十且华西下音着真国林据。斗周电强己其酸美调第构品头。式近意具流从文或深当矿因当化七。',
  //     status: '0',
  //     balance: null,
  //     type: '2',
  //     path: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2Ftp09%2F21031FKU44S6-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1656723242&t=e84685c9a7badca4e7014287eb91f8ed',
  //     task_id: 2,
  //   },
  // ])
  // console.log(tasks.value)
}
</script>

<style lang="scss" scoped>
.scl {
  margin-top: 50px;
  margin-left: 8%;
}
.tl {
  margin-top: 50px;
  margin-left: 8%;
}
</style>
